package com.mylogger;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;

public class MyLoggerFactory implements ILoggerFactory {

	Map<String, Logger>loggerMap = new HashMap<>();
	
	@Override
	public Logger getLogger(String arg0) {
		if (loggerMap.containsKey(arg0)){
			return loggerMap.get(arg0);
		}
		Logger adaptor = new MyLoggerAdaptor(arg0);
		loggerMap.put(arg0, adaptor);
		return adaptor;
	}

	public boolean setLevel( String loggerName, MyLogLevel level){
		if (!loggerMap.containsKey(loggerName)){
			return false;
		}
		( (MyLoggerAdaptor) loggerMap.get(loggerName) ).setLevel(level);
		return true;
	}
}
